package com.itheima.health.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.itheima.health.mapper.MemberMapper;
import com.itheima.health.pojo.Member;
import com.itheima.health.service.MemberService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @author 十一
 * @Description
 * @create 2020-11-06-18:53
 */
@Service
@Transactional
public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> implements MemberService {

    @Autowired
    private MemberMapper memberMapper;

    @Override
    public Member findMemberByTelephone(String telephone) {
        return baseMapper.findMemberByTelephone(telephone);
    }

    @Override
    @LcnTransaction
    public int saveMember(Member member) {
        save(member);
        return member.getId();
    }

    /**
     * 会员占比（按照年龄阶段进行划分）
     * @return
     */
    @Override
    public List<Map> findMemberProportionByAge() {
       return memberMapper.findMemberProportionByAge();
    }

    @Override
    public List<Map> findMemberProportionBySex() {
        return memberMapper.findMemberProportionBySex();

    }

}
